package com.baizhiedu.basic.web;

import com.baizhiedu.basic.pojo.Fighter;
import com.baizhiedu.basic.service.FighterService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: robert.song
 * @Date: Created in 2021/8/5
 */
public class FighterServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
        ApplicationContext app = new ClassPathXmlApplicationContext("/applicationContext.xml");
        FighterService fighterService = (FighterService) app.getBean("fighterService1");
        fighterService.create();
        System.out.println(fighterService.getFighter());
        response.setCharacterEncoding("UTF-8");
    }
}
